package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import pojo.Orderlist;
import service.AdminOrderService;
import service.OrderService;
import service.UserCenterService;
import util.CommonsUtils;

import javax.servlet.http.HttpSession;

@Controller
public class Order {
    @Autowired
    private OrderService orderService;
    @Autowired
    private UserCenterService userCenterService;
    @RequestMapping("/toOrder")
    public String toOrder(Double total, Integer pid,HttpSession session){
        int uid = CommonsUtils.getUserId(session);
        Orderlist orderlist = new Orderlist();
        orderlist.setPid(pid);
        orderlist.setTotal(total);
        orderlist.setUid(uid);
        int a = orderService.aO(orderlist);
        if (a>0){
            System.out.println("付款成功！");
            return "orderSuccess";
        }
        System.out.println("付款失败！");
        return "selectMyCartPage";
    }
}
